package 线程池案例;

/*import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

class ThreadPool {
    private BlockingQueue<Runnable> task = new LinkedBlockingQueue<>();
    private int threadMaxCount = 5;
    public void submit(Runnable task) throws InterruptedException {
        this.task.put(task);
    }
    public ThreadPool() {
        for(int i = 0; i < threadMaxCount; i++){
            Thread t = new Thread(new Runnable() {
                @Override
                public void run() {
                    while(true){
                        try {
                            task.take().run();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            });
            t.start();
        }
    }
}

public class Test4 {
    public static void main(String[] args) throws InterruptedException {
        ThreadPool threadPool = new ThreadPool();
        for(int i = 0; i < 50; i++){
            threadPool.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("线程:" + Thread.currentThread().getName() + "完成了任务");
                }
            });
        }
    }
}*/
